package com.markerhub.config;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
@PropertySource(value = "classpath:application.yml") //指定配置文件的位置
public class AliConfig implements InitializingBean {
    /**
     * 对应公网endpoint地址
     */
    @Value("${aliyun.oss.file.endpoint}")
    private String endpoint;

    /**
     * AccessKeyId
     */
    @Value("${aliyun.oss.file.accessKeyId}")
    private String accessKeyId;

    /**
     * AccessKeySecret
     */
    @Value("${aliyun.oss.file.accessKeySecret}")
    private String accessKeySecret;

    /**
     * Bucket名称
     */
    @Value("${aliyun.oss.file.bucketName}")
    private String bucketName;

    /**
     * 上传文件夹路径
     */
    @Value("${aliyun.oss.file.folder}")
    private String folder;

    public static String END_POINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;
    public static String FOLDER;

    @Override
    public void afterPropertiesSet() throws Exception {
        END_POINT = endpoint;
        ACCESS_KEY_ID = accessKeyId;
        ACCESS_KEY_SECRET = accessKeySecret;
        BUCKET_NAME = bucketName;
        FOLDER = folder;
    }
}
